import {
	request
} from './wxRequest_test';
// export let urlBase_test = 'http://101.207.7.7:18050';

// export let imgUrl = 'http://101.207.7.7:18050/api'
export let imgUrl = 'http://182.151.57.78:9901/api'//政务云图片地址
// export let urlBase_test = 'http://192.168.0.76:18055';//张奇

export let urlBase_test = 'http://182.151.57.78:9901';
// export let urlBase_test2 = 'https://wechat.scyphr.com/v1/'


// export let urlBase_test1 = 'https://lamp.meishifulu.cn/app/v1';
let token = uni.getStorageSync("testCathe");
let deviceId = function() {
	return uni.getStorageSync("USER_INFO").signature;
}

function generateUUID() {
	var d = new Date().getTime();
	var uuid = 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
		var r = (d + Math.random() * 16) % 16 | 0;
		d = Math.floor(d / 16);
		return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
	});
	return uuid;
};

let imgDeviceId = generateUUID();

let access_token = function() {
	// console.log('uni.getStorageSync("access_token")aaaaaaaaaa',uni.getStorageSync("access_token"))
	return uni.getStorageSync("access_token") ? uni.getStorageSync("access_token") : "1234";
};

// let b = new Base64();
let Authorization = "Basic " + "YmV5b25kMjpzZWNyZXQy";
// let Authorization = "Basic "+wx.arrayBufferToBase64("beyond2:secret2");


let commonH = {
	'Authorization': 'Bearer ' + access_token()
}



// 溯源H5接口
// 产品信息详情 /dev-api/api/trace/product/{productId}
export const getProductInfo = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/product/'+params,{},fun,header,'GET')
}
// 修改产品信息 评分 /dev-api/api/trace/product
export const EditEvaluate = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/product',params,fun,header,'PUT')
}

// 查询产品证书  certificateProduct
export const getCertificate = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/certificate/query',params,fun,header,'GET')
}
// 已检项目 /dev-api/api/trace/check/query
export const getcheck = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/check/query',params,fun,header,'GET')
}
// 生产过程 农事记录 /dev-api/api/trace/record/{recordId}
export const getRecord = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/record/query',params,fun,header,'GET')
}
// 原料溯源 /dev-api/api/trace/product/base
export const getbase = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/product/base',params,fun,header,'GET')
}
// 首页 销售门店 /dev-api/api/trace/sale/query
export const getSale = (params,fun,header)=>{
	request(urlBase_test + '/api/trace/sale/query',params,fun,header,'GET')
}






// 登录接口
export const login = (params,fun,header)=>{
	request(urlBase_test + '/login',params,fun,header,'POST')
}

// 重庆海关设备列表
export const getEquipList = (params,fun,header)=>{
	request(urlBase_test + '/device/info/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// api/device/info/check?departId=1 监测情况 根据基地查询
export const getEquipList2 = (params,fun,header)=>{
	request(urlBase_test + '/device/info/check',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 隶属海关获取基地列表 传userId 
export const getBaseList = (params,fun,header)=>{
	request(urlBase_test + '/departs/info/query/'+params.userId,{},fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}

// 重庆海关设备的图片列表
export const getPicList = (params,fun,header)=>{
	request(urlBase_test + '/device/photograph/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 气象历史数据
export const getWeaHistory = (params,fun,header)=>{
	request(urlBase_test + '/device/history/rest/getHistory',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 海关列表
export const getDepartmentList = (params,fun,header)=>{
	request(urlBase_test + '/departs/info/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 设备情况 数量列表
export const getEquipInfoList = (params,fun,header)=>{
	request(urlBase_test + '/device/info/query',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
//   诱剂种类
export const getReagentTypeList = (params,fun,header)=>{
	request(urlBase_test + '/devicebait/category/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 新增诱剂
export const addReagent = (params,fun,header)=>{
	request(urlBase_test + '/device/bait',params,fun,{'Authorization': 'Bearer ' + access_token()},'PUT')
}
// 直属海关 设备/诱剂种类 
export const getEquipNum = (params,fun,header)=>{
	request(urlBase_test + '/device/info/collect',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 收虫维护
export const getMaintainList = (params,fun,header)=>{
	request(urlBase_test + '/device/pestUphold/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 提交收虫 
export const submitInsects = (params,fun,header)=>{
	request(urlBase_test + '/device/pestUphold',params,fun,{'Authorization': 'Bearer ' + access_token()},'POST')
}
// 诱剂种类 诱剂列表
export const getReagentListInfo = (params,fun,header)=>{
	request(urlBase_test + '/device/bait/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
//  诱剂详情
export const getReagentDetails = (params,fun,header)=>{
	request(urlBase_test + '/device/bait/'+params.id,{},fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 布点  设备列表
export const getBaseEquipList = (params,fun,header)=>{
	request(urlBase_test + '/device/info/list',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 根据果园展示设备
export const getBaseEquipList2 = (params,fun,header)=>{
	request(urlBase_test + '/device/info/hang',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}
// 预警消息
export const getWarningMessage = (params,fun,header)=>{
	request(urlBase_test + '/device/info/prompt',params,fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}

// 根据字典类型查询字典数据信息
export const getDicts = (params,fun,header)=>{
	request(urlBase_test + '/system/dict/data/type/'+params,{},fun,{'Authorization': 'Bearer ' + access_token()},'GET')
}

// 获取用户信息
export const getUserInfo = (params,fun,header)=>{
	request(urlBase_test + '/getInfo',params,fun,header,'GET')
}
//获取图片验证码
export const _formLoginImgCode = function(params, fun, header) {
	request(urlBase_test + '/captchaImage', params, fun, header, 'GET')
}

// 重庆海关获取识别的虫类
export const getImgDetail = function(params, fun, header) {
	request(urlBase_test + '/device/result/list', params, fun,header, 'GET')
};
// 重庆海关获取虫情数据
export const getEquipDetail = function(params, fun, header) {
	request(urlBase_test + '/device/real/list', params, fun,header, 'GET')
};



